package tttrung43.libs.android;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Connection {
	private Context context;
	private DBAdapter dbadapter;
	private SQLiteDatabase db;

	public Connection(Context context) {
		this.context = context;
		dbadapter = new DBAdapter(this.context);
	}

	public void AddData(String sql) {
		db = dbadapter.getWritableDatabase();
		db.execSQL(sql);
		db.close();
	}

	public void Close() {
		db.close();
	}

	public Cursor GetData(String sql) {
		try {
			db = dbadapter.getReadableDatabase();
			return db.rawQuery(sql, null);
		} catch (Exception ex) {
			return null;
		}
	}
}
